package com.github.wxiaoqi.security.biz.feign;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.wxiaoqi.security.biz.biz.BhFunctionBiz;
import com.github.wxiaoqi.security.biz.biz.BhIndustryBiz;
import com.github.wxiaoqi.security.biz.biz.BhResumUsedBiz;
import com.github.wxiaoqi.security.biz.biz.BhTaskBiz;
import com.github.wxiaoqi.security.biz.biz.BhTaskTagBiz;
import com.github.wxiaoqi.security.biz.entity.BhIndustry;
import com.github.wxiaoqi.security.biz.entity.BhTask;
import com.github.wxiaoqi.security.common.msg.ResponseCode;

import javaslang.collection.Array;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Controller
@RequestMapping("userCenter/api")
public class UserCenterApi {
	@Autowired
	private BhIndustryBiz bhIndustryBiz;
	@Autowired
	private BhFunctionBiz bhFunctionBiz;
	@Autowired
	private BhTaskTagBiz bhTaskTagBiz;
	@Autowired
	private BhResumUsedBiz bhResumUsedBiz;
	@Autowired
	private BhTaskBiz bhTaskBiz;
	/**
	 * 猎手中心
	 */
	@RequestMapping(value = "/hunterCenterInfo", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> hunterCenterInfo(@RequestBody Map<String, Object> req){
		Map<String, Object> result = new HashMap<String, Object>();
		String custNo = (String) req.get("custNo");
		if(null == custNo || "".equals(custNo)){
			result.put("code", ResponseCode.INVALID_FIELDS.getCode());
			result.put("msg", ResponseCode.INVALID_FIELDS.getMessage());
			return result;
		}
		try {
			//关注的行业匹配悬赏
			int industryCount = bhIndustryBiz.queryIndustryRewardCount(req);
			// 关注的职位匹配悬赏
			int functionCount = bhFunctionBiz.queryFunctionRewardCount(req);
			// 我的标签匹配悬赏
			int tagCount = bhTaskTagBiz.queryTagReward(req);
			//昨天被查看简历数
			int viewCount = bhResumUsedBiz.queryViewedResumen(req);
			//昨天被淘汰简历数
			int failedCount = bhResumUsedBiz.queryOutResumen(req);
			result.put("industryCount", industryCount);
			result.put("functionCount", functionCount);
			result.put("tagCount", tagCount);
			result.put("viewCount", viewCount);
			result.put("failedCount", failedCount);
			result.put("code", ResponseCode.OK.getCode());
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", ResponseCode.ABNORMAL_FIELDS.getCode());
			result.put("msg", ResponseCode.ABNORMAL_FIELDS.getMessage());
		}
		return result;
	}
	/**
	 * 悬赏中心
	 */
	@RequestMapping(value = "/rewardCenterInfo", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> rewardCenterInfo(@RequestBody Map<String, Object> req){
		Map<String, Object> map = new HashMap<String, Object>();
		String merNo = (String) req.get("merNo");
		if(null == merNo || "".equals(merNo)){
			map.put("code", ResponseCode.INVALID_FIELDS.getCode());
			map.put("msg", ResponseCode.INVALID_FIELDS.getMessage());
			return map;
		}
		try {
			//收到待查看简历
			Integer noViewedCount = bhResumUsedBiz.queryNoView(req);
			//进行中的任务
			Integer runningCount = bhTaskBiz.queryRuningTask(req);
			map.put("noViewedCount", noViewedCount);
			map.put("runningCount", runningCount);
			map.put("code", ResponseCode.OK.getCode());
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", ResponseCode.ABNORMAL_FIELDS.getCode());
		}
		
		return map;
	}
}
